{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "intro",
   "metadata": {},
   "source": [
    "# Introduction to Collections in Python"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "concepto",
   "metadata": {},
   "source": [
    "## Step 1: What are Collections?\n",
    "In Python, collections are a way to store multiple values in a single variable. They are useful when you need to handle more than one piece of data at once. There are different types of collections, each serving different purposes."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "tipos-lista",
   "metadata": {},
   "source": [
    "Python provides several built-in collection types:\n",
    "- **Lists** (`list`): Ordered and mutable collections. You can modify them after creation.\n",
    "- **Tuples** (`tuple`): Ordered collections, but immutable. Once created, you cannot change their elements.\n",
    "- **Sets** (`set`): Unordered collections that cannot have duplicate values.\n",
    "- **Dictionaries** (`dict`): Store data in key-value pairs, making it easy to retrieve information based on a key."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "list",
   "metadata": {},
   "source": [
    "## Step 2: Lists\n",
    "A list is a collection that is ordered (the order of items is preserved) and mutable (you can change its contents). You can add, remove, or modify items in a list.\n",
    "Here is an example where we create a list of fruits and perform some operations on it:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "codigo-list",
   "metadata": {},
   "outputs": [],
   "source": [
    "fruits = ['apple', 'banana', 'cherry']\n",
    "# Access the first item in the list\n",
    "print(fruits[0])  # Output: apple\n",
    "# Add a new item to the list\n",
    "fruits.append('orange')\n",
    "# Now the list is updated\n",
    "print(fruits)  # Output: ['apple', 'banana', 'cherry', 'orange']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "tuple",
   "metadata": {},
   "source": [
    "## Step 3: Tuples\n",
    "A tuple is like a list, but it is **immutable**. Once you create a tuple, you cannot change its contents. This is useful for storing data that should not be modified.\n",
    "In this example, we define a tuple and access its elements:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "codigo-tuple",
   "metadata": {},
   "outputs": [],
   "source": [
    "coordinates = (10, 20)\n",
    "# Access the second element in the tuple\n",
    "print(coordinates[1])  # Output: 20"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "set",
   "metadata": {},
   "source": [
    "## Step 4: Sets\n",
    "A set is an unordered collection of unique elements. Sets do not allow duplicate values, so if you try to add the same item twice, it will only appear once.\n",
    "In the following example, we define a set and see how duplicates are removed automatically:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "codigo-set",
   "metadata": {},
   "outputs": [],
   "source": [
    "unique_numbers = {1, 2, 3, 3, 4}\n",
    "# Duplicates are automatically removed when we create the set\n",
    "print(unique_numbers)  # Output: {1, 2, 3, 4}"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dict",
   "metadata": {},
   "source": [
    "## Step 5: Dictionaries\n",
    "Dictionaries are collections of **key-value pairs**. Each item in a dictionary has a key and an associated value. They are used when you need to store data and quickly retrieve it using the key.\n",
    "In the example below, we define a dictionary to store a person's name and age:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "codigo-dict",
   "metadata": {},
   "outputs": [],
   "source": [
    "person = {'name': 'Alice', 'age': 25}\n",
    "# Access the value associated with the 'name' key\n",
    "print(person['name'])  # Output: Alice"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ejercicio",
   "metadata": {},
   "source": [
    "## Step 6: Practical Exercise\n",
    "Now, let's practice what we've learned. Create a program that asks for three of your favorite fruits, stores them in a list, and then prints the list."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ejercicio-2",
   "metadata": {},
   "source": [
    "### Exercise 1: Reverse a List\n",
    "Write a program that creates a list of your favorite numbers and reverses the order of the list.\n",
    "Hint: Use the `reverse()` method to reverse the list in place."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ejercicio-3",
   "metadata": {},
   "source": [
    "### Exercise 2: Tuple Operations\n",
    "Write a program that creates a tuple with some elements and prints the second element of the tuple.\n",
    "Hint: Remember that indexing starts at 0, so the second element has index `1`."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ejercicio-4",
   "metadata": {},
   "source": [
    "### Exercise 3: Set Operations\n",
    "Create a set with several numbers, add a new number to the set, and print the set before and after adding the new number."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ejercicio-5",
   "metadata": {},
   "source": [
    "### Exercise 4: Dictionary Lookup\n",
    "Write a program that creates a dictionary with information about a person (e.g., name, age) and prints the person's name."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.x"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
